home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / sprite.X11R3 / hdr / memvar.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-03  |  4.8 KB  |  151 lines

  1. /* @(#)memvar.h 1.43 89/03/19 SMI */
  2.  
  3. /*
  4.  * Copyright 1986-1989 Sun Microsystems, Inc.
  5.  */
  6.  
  7. #ifndef    memvar_DEFINED
  8. #define    memvar_DEFINED
  9.  
  10. /*
  11.  * A memory pixrect is a special type of pixrect.  Its image resides in
  12.  * memory, in a publicly known format permitting more direct access to the
  13.  * image than possible with the general pixrectops.
  14.  *
  15.  * In the memory pixrect the image is stored in consecutive
  16.  * memory locations, across the row from left to right, and then from top
  17.  * row to bottom.  Row boundaries come at shortword boundaries whence
  18.  * rows have an even number of bytes.
  19.  *
  20.  * The depth of a pixel is the number of bits required to represent it.
  21.  * Pixels are placed in consecutive fields of width the depth of each pixel,
  22.  * with placement being independent of word or byte boundaries.
  23.  */
  24. struct mpr_data {
  25.     int    md_linebytes;    /* number of bytes from one line to next */
  26.     short    *md_image;    /* word address */
  27.     struct    pr_pos md_offset;
  28.     short    md_primary;
  29.     short    md_flags;    /* Flag bits, see below */
  30. };
  31.  
  32. /* pixrect data for memory pixrect with plane mask (MP_PLANEMASK set) */
  33. struct mprp_data {
  34.         struct mpr_data    mpr;
  35.         int        planes;
  36. };
  37.  
  38. #define mpr_d(pr)    ((struct mpr_data *) (pr)->pr_data)
  39. #define mprp_d(pr)    ((struct mprp_data *) (pr)->pr_data)
  40.  
  41. /* md_flags bits definitions */
  42.  
  43. #define MP_REVERSEVIDEO    1    /* Pixrect is reverse video */
  44.                 /* (should only be set if pr_depth = 1) */
  45. #define MP_DISPLAY    2    /* Pixrect is a frame buffer device */
  46. #define MP_PLANEMASK    4    /* Pixrect has a plane mask */
  47.                 /* (should only be set if pr_depth > 1) */
  48. #ifdef i386
  49. #define MP_I386        8    /* Pixrect is for 386 architecture */
  50. #define MP_STATIC       16    /* Pixrect is a static pixrect */
  51. #endif i386
  52. #define    MP_FONT        32    /* Pixrect is a part of a Pixfont */
  53.                 /* (hint to pr_batchrop) */
  54.  
  55. /* 
  56.  * Each line (row) of the pixrect is padded to be a multiple
  57.  * of this many bits 
  58.  */
  59. #define MPR_LINEBITPAD    16
  60.  
  61. #define    mpr_linebytes(x, depth)                        \
  62.     ( ((pr_product(x, depth) + (MPR_LINEBITPAD-1)) >> 3) &~ 1)
  63. #define mpr_prlinebytes(mpr)                        \
  64.     mpr_linebytes((mpr)->pr_size.x, (mpr)->pr_depth)
  65. #define    mpr_mdlinebytes(mpr)                        \
  66.     (mpr_d(mpr)->md_linebytes)
  67.  
  68. #define mprd_addr(mprd, xo, yo)                        \
  69.     ((short *)(                            \
  70.         (int)(mprd)->md_image                                       \
  71.         + pr_product((mprd)->md_linebytes,(mprd)->md_offset.y+(yo)) \
  72.         + (((mprd)->md_offset.x+(xo)) >> 3) &~ 1))
  73.  
  74. #define mprd8_addr(mprd, xo, yo, d)                    \
  75.      ((u_char *)(                            \
  76.          (int)(mprd)->md_image                    \
  77.         + pr_product((mprd)->md_linebytes,(mprd)->md_offset.y+(yo)) \
  78.         + (pr_product((mprd)->md_offset.x+(xo), (d)) >> 3) )  )
  79.  
  80. #define    mprd_skew(mprd, xo, yo)                        \
  81.     (((mprd)->md_offset.x + (xo)) & 15)
  82.  
  83. #define    mprs_addr(mprs)        _mprs_addr((struct pr_prpos *)&(mprs))
  84. #define    mprs8_addr(mprs)    _mprs8_addr((struct pr_prpos *)&(mprs))
  85. #define    mprs_skew(mprs)        _mprs_skew((struct pr_prpos *)&(mprs))
  86.  
  87. #if !defined lint || !defined KERNEL || defined(sun2)
  88. short    *_mprs_addr();
  89. u_char    *_mprs8_addr();
  90. int    _mprs_skew();
  91. #endif
  92.  
  93. /*
  94.  * Static pixrects.  A pixrect may be created at compile time using the
  95.  * mpr_static macro as part of the static declarations of a program.  Thus
  96.  * mpr_static(cursor, 16, 16, 1, rawcursordata);
  97.  * will declare and initialize (using rawcursordata) the storage needed
  98.  * for a pixrect that may be referred to as 'cursor' subsequently in the
  99.  * same file, or as &cursor if a pointer to that pixrect is called for rather
  100.  * than the pixrect itself.
  101.  */
  102.  
  103. /* First a pair of utility macros that allow concatenation in a fashion that
  104.  * won't annoy lint (These belong in a standard header file!):
  105.  */
  106. #ifndef    CAT
  107. #undef    IDENT
  108. #define IDENT(x)    x
  109. #define    CAT(a,b)    IDENT(a)b
  110. #endif
  111.  
  112. #define mpr_static(name, w, h, d, image) \
  113.     struct mpr_data CAT(name,_data) = \
  114.         {mpr_linebytes(w,d), (short *)(image), {0, 0}, 0, 0}; \
  115.     Pixrect name = {&mem_ops, w, h, d, (caddr_t)&CAT(name,_data)}
  116.  
  117. /* static pixrect with variables declared "static" */
  118. #define    mpr_static_static(name, w, h, d, image) \
  119.     static struct mpr_data CAT(name,_data) = \
  120.         {mpr_linebytes(w,d), (short *)(image), {0, 0}, 0, 0}; \
  121.     static Pixrect name = {&mem_ops, w, h, d, (caddr_t)&CAT(name,_data)}
  122.  
  123. /*
  124.  * During rop calls need to determine if dst/src is something that
  125.  * mem_rop() can handle.  Use the following macro to find out.
  126.  */
  127. #define    MP_NOTMPR(pr)    ((pr)->pr_ops->pro_rop != mem_rop)
  128.  
  129. extern struct pixrectops mem_ops;
  130.  
  131. int    mem_rop();
  132. #ifndef KERNEL
  133. int    mem_stencil();
  134. int    mem_batchrop();
  135. Pixrect *mem_create();        /* General mpr create routine */
  136. Pixrect *mem_point();        /* Even more general mpr create */
  137. int    mem_destroy();
  138. int    mem_get();
  139. int    mem_put();
  140. int    mem_vector();
  141. Pixrect *mem_region();
  142. #endif KERNEL
  143. int    mem_putcolormap();
  144. int    mem_putattributes();
  145. #ifndef KERNEL
  146. int    mem_getcolormap();
  147. int    mem_getattributes();
  148. #endif KERNEL
  149.  
  150. #endif    !memvar_DEFINED
  151.